package com.wyj.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * TODO: mvc配置
 *
 * @author wuyijie
 * @date 2021/12/20 5:51 下午
 */
@Configuration
public class MyWebMvcConfiguration implements WebMvcConfigurer {
    private final LoginInterceptor loginInterceptor;

    public MyWebMvcConfiguration(LoginInterceptor loginInterceptor) {
        this.loginInterceptor = loginInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        WebMvcConfigurer.super.addInterceptors(registry);
        //添加相关拦截器并添加拦截路径和排除路径；登录接口，无需拦截；
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**").excludePathPatterns("/login");
    }
}
